package com.leyou.gateway.config;

import com.leyou.common.auth.utils.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.security.PrivateKey;
import java.security.PublicKey;

/**
 * 读取jwt配置信息
 */
@Data
@Component
@ConfigurationProperties(prefix = "ly.jwt")
public class JwtProperties {
    private String pubKeyPath;//公钥路径

    private PublicKey publicKey;//公钥对象

    //通过路径获取公私钥对象
    @PostConstruct // 标记为初始化方法
    public void init() throws Exception {
        publicKey = RsaUtils.getPublicKey(pubKeyPath);
    }

    //接收cookie中的属性
    private CookiePojo cookie = new CookiePojo();

    //接收app的属性
    private AppPojo app = new AppPojo();

    @Data
    public class CookiePojo{
        private String cookieName;
    }

    @Data
    public class AppPojo{
        private String serviceName;
        private String secret;
    }
}
